import Vue from 'vue'
import htUpload, { service } from 'ht-upload'
import { ACCESS_TOKEN } from "@/store/mutation-types"

service.interceptors.request.use(
  config => {
    // 在请求发送之前做一些处理，根据项目实际情况自行处理要携带的信息
    const token = Vue.ls.get(ACCESS_TOKEN)
    config.headers['X-Access-Token'] = token
    config.headers['Content-Type'] = 'application/json'
    return config
  },
  error => {
    // 发送失败
    console.log('request rejected', error)
    return Promise.reject(error)
  }
)
service.defaults.baseURL = process.env.VUE_APP_API_BASE_URL
service.defaults.timeout = process.env.VUE_APP_REQUEST_TIMEOUT
Vue.use(htUpload)
